layui.use(['layer','carousel','element',"form"], function(){
    //首页轮播图接口请求
    getCarouselList(function(res){
        if(res.code==="0"){
            console.log(123)
            for(var i in res.data){
                $('.carousel-item').append("<img src='"+res.data[i].imgUrl+"'>");
               } 
           var carousel = layui.carousel;
           var element = layui.element;
           //建造实例
           carousel.render({
               elem: '#top-swiper'
               ,width: '100%' //设置容器宽度
               ,height: '100%'
               ,arrow: 'always' //始终显示箭头
               //,anim: 'updown' //切换动画方式
           });
           carousel.render({
               elem: '#z-curse'
               ,width: '100%' //设置容器宽度
               ,height: '100%'
               ,arrow: 'always' //始终显示箭头
               //,anim: 'updown' //切换动画方式
           });
           carousel.render({
               elem: '#j-curse'
               ,width: '100%' //设置容器宽度
               ,height: '100%'
               ,arrow: 'always' //始终显示箭头
               //,anim: 'updown' //切换动画方式
           });
           
        }else{
            layer.msg(res.msg); 
        }
    })
    
    var form = layui.form;

    //监听提交
    form.on('submit(formDemo)', function(data){
        layer.msg(JSON.stringify(data.field));
        return false;
    });
});
var CoursePageData={
	type:2
}
getCoursePage(CoursePageData,function(res){
    console.log(res)
})
getLiveCourseList(function(res){
	if(res.code==0){
		
	}else{
		layer.msg(res.msg); 
	}
})
//获取直播列表
getLiveCourseList(function(res){
	if(res.code==0){
		var data=res.data;
		for(var i in data){
			var imgUrl=data[i].imgUrl||'';
			var curseItem='<li class="curse-live"><a href="javascript:;" class="cur-live-img"><img src="'+imgUrl+'" alt=""></a><a href="javascript:;" class="curse-name">电商banner设计进阶班进阶班进阶</a><div class="teachers"><a href="javascript:;" class="teacher-head"><img src="" alt=""></a><p class="teacher-name">甄妮</p></div><p class="has-learn"><i>265456</i>人已学过</p></li>'
			$('.curse-live-list').append(curseItem);								
		}
	}else{
		layer.msg(res.msg); 
	}
})
//获取老师推荐列表
getTeacherPage({
	limit:10,
	offset:1
},function(res){
	if(res.code==0){
		var data=res.data
		for(var i in data){
			var imgUrl=data[i].imgUrl||'';
			var name=data[i].name||'';
			var postname=data[i].postname||'';
			var	teacher_intro ="<li class='teacher-intro'><a href='javascript:;' class='teacher-head'><img src='"+imgUrl+"' alt=''></a><strong class='r-teacher-name'>"+name+"</strong><p class='r-teacher-occu'>"+postname+"</p></li>"
			$('.reco-cate-d').append(teacher_intro);
		}
	}else{
		layer.msg(res.msg); 
	}
})


